import 'package:flutter/material.dart';
import 'package:kasax_demos2/entry/data_posts_test.dart';
import 'package:kasax/utils/img_utils.dart';

class DividerDemo extends StatefulWidget {
  const DividerDemo({Key? key}) : super(key: key);

  @override
  _DividerDemoState createState() => _DividerDemoState();
}

class _DividerDemoState extends State<DividerDemo> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("DividerDemo"),
      ),
      body: ListView.separated(
          itemBuilder: (context, index) {
            var post = PostsDatas.TEST_POSTS[index];
            return Container(
              padding: EdgeInsets.all(10),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Row(
                    children: [
                      Text(
                        "${post.title}",
                        textAlign: TextAlign.start,
                      ),
                      Expanded(child: Container()),
                      Text(
                        "${post.author}",
                        textAlign: TextAlign.end,
                      ),
                    ],
                  ),
                  SizedBox(
                    height: 5,
                  ),
                  ImageUtils.buildRoundImgByCard(post.imageUrl),
                  SizedBox(
                    height: 5,
                  ),
                  Text("${post.description}"),
                ],
              ),
            );
          },
          separatorBuilder: (context, index) {
            return Divider(
              indent: 30,
              endIndent: 30,
              color: Colors.grey.shade700,
            );
          },
          itemCount: PostsDatas.TEST_POSTS.length),
    );
  }
}
